package com.example.airport.data;

import java.util.LinkedList;

public class FixedSizeLinkedList<T> {
    private final int maxSize;
    private final LinkedList<T> list;

    public FixedSizeLinkedList(int size) {
        this.maxSize = size;
        this.list = new LinkedList<>();
    }

    public void push(T element) {
        list.addLast(element);
        while (list.size() > maxSize) {
            list.removeFirst();
        }
    }

    public T get(int index) {
        return list.get(index);
    }


    public String toString()
    {
        return list.toString();
    }

    public int size()
    {
        return list.size();
    }

    public void clear()
    {
        list.clear();


    }
    public T first()
    {
        return list.get(0);

    }
    // 其他必要的方法，例如size(), isEmpty()等


}